package com.cn.system.controller;

import com.cn.common.result.Result;
import com.cn.model.system.SysDept;
import com.cn.system.service.SysDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "部门管理")
@RestController
@RequestMapping("/admin/system/sysDept")
@CrossOrigin
public class SysDeptController {
    @Autowired
    private SysDeptService sysDeptService;


    @ApiOperation(value = "部门列表")
    @GetMapping("findNodes")
    public Result findNodes() {
        List<SysDept> list = sysDeptService.findNodes();
        return Result.ok(list);
    }

    @ApiOperation(value = "新增部门")
    @PostMapping("save")
    public Result save(@RequestBody SysDept permission) {
        sysDeptService.save(permission);
        return Result.ok();
    }

    @ApiOperation(value = "修改")
    @PutMapping("update")
    public Result updateById(@RequestBody SysDept permission) {
        sysDeptService.updateById(permission);
        return Result.ok();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("remove/{id}")
    public Result remove(@PathVariable Long id) {
        sysDeptService.removeById(id);
        return Result.ok();
    }
}
